From: Andrew Cooper Date: Wed, 23 Sep 2015 09:16:08 +0000 (+0200) Subject: x86/hvm: refine hap_has_{2mb,1gb} checks X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2509 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=4db520bcf75a101ce7e06cdca52350c100a8e67e;p=xen.git x86/hvm: refine hap_has_{2mb,1gb} checks HAP superpages are a host property and not dependent on domain configuration. Drop the domain paramter (which was only used in one of the two callsites), and drop the redundant hvm_ prefix to mirror the cpu_has_* style of feature detection. Finally, convert the checks to being proper booleans rather than just non-zero integers. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Acked-by: George Dunlap --- diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 58db34ef5c..dde242e3c0 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -696,8 +696,8 @@ ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, if ( ret > 0 ) needs_sync = sync_on; - ASSERT((target == 2 && hvm_hap_has_1gb()) || - (target == 1 && hvm_hap_has_2mb()) || + ASSERT((target == 2 && hap_has_1gb) || + (target == 1 && hap_has_2mb) || (target == 0)); ASSERT(!p2m_is_foreign(p2mt) || target == 0); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 87b6a16026..1eda2c8064 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -452,9 +452,9 @@ int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, { if ( hap_enabled(d) ) order = ( (((gfn | mfn_x(mfn) | todo) & ((1ul << PAGE_ORDER_1G) - 1)) == 0) && - hvm_hap_has_1gb(d) && opt_hap_1gb ) ? PAGE_ORDER_1G : + hap_has_1gb && opt_hap_1gb) ? PAGE_ORDER_1G : ((((gfn | mfn_x(mfn) | todo) & ((1ul << PAGE_ORDER_2M) - 1)) == 0) && - hvm_hap_has_2mb(d) && opt_hap_2mb) ? PAGE_ORDER_2M : PAGE_ORDER_4K; + hap_has_2mb && opt_hap_2mb) ? PAGE_ORDER_2M : PAGE_ORDER_4K; else order = 0; diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 9f49e6dc71..0693706364 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -278,10 +278,8 @@ int hvm_girq_dest_2_vcpu_id(struct domain *d, uint8_t dest, uint8_t dest_mode); (!!((v)->arch.hvm_vcpu.guest_efer & EFER_NX)) /* Can we use superpages in the HAP p2m table? */ -#define hvm_hap_has_1gb(d) \ - (hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB) -#define hvm_hap_has_2mb(d) \ - (hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB) +#define hap_has_1gb (!!(hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB)) +#define hap_has_2mb (!!(hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB)) /* Can the guest use 1GB superpages in its own pagetables? */ #define hvm_pse1gb_supported(d) \